<?php

namespace App\Http\Controllers\Userinfo;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
    use AuthenticatesUsers;
    protected $redirectTo = '/';
    protected function __construct()
    {
        $this -> middleware('guest.userinfo',['except'=>'logout']);
    }
    /**
     * 显示前端模板
     */
    public function showLoginForm()
    {
        return view('shop.login');
    }
    protected function guard()
    {
        return auth() -> guard('userinfo');
    }
    public function username()
    {
        return 'name';
    }
    public function logout()
    {
        $this -> guard() -> logout();
        $request -> session() -> forget($this->guard()->getName());
        $request -> session() -> regenerate();
        return redirect('/');
    }
}
